{include file="index/header" /}
<body>
	<form method="post" action="" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head"><strong class="icon-reorder"> 内容列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
					<li> <a class="button border-main icon-plus-square-o" href="{:url('edit')}"> 添加内容</a> </li>
					<li>搜索：</li>
					<li>
						<select name="nav_id" class="input" style="width:200px; line-height:17px;" onchange="changeNav()"  id="nav">
							<option value="">请选择专业</option>
							{foreach name='nav_data' item='nav'}
							<option value="{$nav.nav_id}" {if $nav.nav_id eq $nav_id} selected=""{/if}>{$nav.nav_name}</option>
							{/foreach}
						</select>
					</li>
					<li>
						<select name="type_id" class="input" style="width:200px; line-height:17px;" onchange="changesearch()" id="type">
							<option value="">请选择阶段</option>
							{foreach name='type_data' item='type'}
							<option value="{$type.type_id}"  {if $type.type_id eq $type_id} selected=""{/if}>{$type.type_name}</option>
							{/foreach}
						</select>
					</li>
					<li>
						<input type="text" placeholder="请输入搜索关键字" name="keywords" class="input" style="width:250px; line-height:17px;display:inline-block" value="{$keywords}" />
						<a href="javascript:void(0)" class="button border-main icon-search" onclick="changesearch()" > 搜索</a>
					</li>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
					<th width="100" style="text-align:left; padding-left:20px;">ID</th>
					<th width="10%">排序</th>
					<th>名称</th>
					<th>发布人</th>
					<th>专业</th>
					<th>阶段</th>
					<th width="310">操作</th>
				</tr>
				{foreach name='data' item='v'}
				<tr>
					<td style="text-align:left; padding-left:20px;"><input type="checkbox" name="s_id[]" value="{$v.s_id}" />
					{$v.s_id}</td>
					<td><input type="text" name="s_sort[{$v.s_id}]" value="{$v.s_sort}" style="width:50px; text-align:center; border:1px solid #ddd; padding:7px 0;" /></td>
					<td width="10%">{$v.s_name}{:returnSpecifcShow($v.s_show)}</td>
					<td width="10%">{$v.admin_name}</td>
					<td>{$v.nav_name}</td>
					<td><font color="#00CC99">{$v.type_name}</font></td>
					<td>
						<div class="button-group">
							<a class="button border-main" href="{:url('edit',['s_id' => $v['s_id']])}"><span class="icon-edit"></span> 修改</a> 
							<a class="button border-red" href="{:url('delete',['s_id' => $v['s_id']])}"  onclick="if(confirm('确定删除?')==false)return false;"><span class="icon-trash-o"></span> 删除</a>
						</div>
					</td>
				</tr>
				{/foreach}
				<tr>
					<td style="text-align:left; padding:19px 0;padding-left:20px;"><input type="checkbox" id="checkall"/>
					全选 </td>
					<td colspan="8" style="text-align:left;padding-left:20px;"><a href="javascript:void(0)" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 删除</a> <a href="javascript:void(0)" style="padding:5px 15px; margin:0 10px;" class="button border-blue icon-edit" onclick="sorts()"> 排序</a> 
					</td>
				</tr>
				<tr>
					<td colspan="8">{$data->render()}</td>
				</tr>
			</table>
		</div>
		<input type="hidden" name="status" value="">
	</form>

	<script type="text/javascript">
		function changesearch(){  
			$('input[name=status]').val('select');
			$("#listform").submit();
		}

		function changeNav(){
			$('input[name=status]').val('select');
			$("#listform").submit();
		}


		$("#checkall").click(function(){ 
			$("input[name='s_id[]']").each(function(){
				if (this.checked) {
					this.checked = false;
				}
				else {
					this.checked = true;
				}
			});
		})
		function DelSelect(){
			var Checkbox=false;
			$("input[name='s_id[]']").each(function(){
				if (this.checked==true) {   
					Checkbox=true;  
				}
			});
			if (Checkbox){
				var t=confirm("您确认要删除选中的内容吗？");
				if (t==false) return false;   
				$('input[name=status]').val('del');
				$("#listform").submit();    
			}
			else{
				alert("请选择您要删除的内容!");
				return false;
			}
		}
		function sorts(){
			var Checkbox=false;
			$("input[name='s_id[]']").each(function(){
				if (this.checked==true) {   
					Checkbox=true;  
				}
			});
			if (Checkbox){  
				$('input[name=status]').val('sort');
				$("#listform").submit();    
			}
			else{
				alert("请选择要操作的内容!");
				return false;
			}
		}
		function changecate(o){
			var Checkbox=false;
			$("input[name='s_id[]']").each(function(){
				if (this.checked==true) {   
					Checkbox=true;  
				}
			});
			if (Checkbox){    
				$('input[name=status]').val('move');
				$("#listform").submit();    
			}
			else{
				alert("请选择要操作的内容!");

				return false;
			}
		}
		$('#nav').change(function(){
			var nav_id = $(this).val();
			$("#type option:gt(0)").remove();
			$("#s option:gt(0)").remove();
			if(nav_id == ''){
				return;
			}
			$.ajax({
				type:'GET',
				url :"{:url('course/getType')}",
				data:'nav_id='+nav_id,
				dataType:'json',
				success : function(data){
					$.each(data, function(k,v){
						$('#type').append('<option value="'+v.type_id+'">'+v.type_name+'</option>');
					});
				}
			});
		});
	</script>
</body>
</html>